/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.database.metamodel;

import java.sql.ResultSet;
import java.sql.SQLException;


public class Index extends BaseDatabaseEntity {
    String ascOrDesc;
    String columnName;
    String filterCondition;
    String indexName;
    String indexQualifier;
    String tableCatalog;
    String tableName;
    String tableSchema;
    boolean nonUnique;
    int cardinality;
    int pages;
    short ordinalPosition;
    short type;

    public void setAscOrDesc(String ascOrDesc) {
        this.ascOrDesc = ascOrDesc;
    }

    public String getAscOrDesc() {
        return ascOrDesc;
    }

    public void setCardinality(int cardinality) {
        this.cardinality = cardinality;
    }

    public int getCardinality() {
        return cardinality;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setFilterCondition(String filterCondition) {
        this.filterCondition = filterCondition;
    }

    public String getFilterCondition() {
        return filterCondition;
    }

    public void setIndexName(String indexName) {
        this.indexName = indexName;
    }

    public String getIndexName() {
        return indexName;
    }

    public void setIndexQualifier(String indexQualifier) {
        this.indexQualifier = indexQualifier;
    }

    public String getIndexQualifier() {
        return indexQualifier;
    }

    public void setNonUnique(boolean nonUnique) {
        this.nonUnique = nonUnique;
    }

    public boolean isNonUnique() {
        return nonUnique;
    }

    public void setOrdinalPosition(short ordinalPosition) {
        this.ordinalPosition = ordinalPosition;
    }

    public short getOrdinalPosition() {
        return ordinalPosition;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getPages() {
        return pages;
    }

    public void setTableCatalog(String tableCatalog) {
        this.tableCatalog = tableCatalog;
    }

    public String getTableCatalog() {
        return tableCatalog;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableSchema(String tableSchema) {
        this.tableSchema = tableSchema;
    }

    public String getTableSchema() {
        return tableSchema;
    }

    public void setType(short type) {
        this.type = type;
    }

    public short getType() {
        return type;
    }

    public void assign(ResultSet crs) throws SQLException {
        setIndexQualifier(crs.getString(5));
        setIndexName(crs.getString(6));
        setNonUnique(crs.getBoolean(2));
        setType(crs.getShort(7));
        setColumnName(crs.getString(9));
        setOrdinalPosition(crs.getShort(8));
        setAscOrDesc(crs.getString(10));
        setCardinality(crs.getInt(11));
        setPages(crs.getInt(12));
        setFilterCondition(crs.getString(13));
    }
}
